using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;


namespace Framework.Library.Utilities
{
    public class EmailUtility
    {
        //public static bool DoSendMail(string server, string user, string password,string from, string to, string cc, string subject, string content, bool format)
        public static bool DoSendMail(string server, string from, string to, string cc, string subject, string content, bool format)
        {
            MailMessage message = new MailMessage();
            SmtpClient SmtpMail = new SmtpClient();
            SmtpMail.Port = 25;
            SmtpMail.Host = server;            
            message.To.Add(to);
            message.From = new MailAddress(from,from);
            if(cc!="")
                message.CC.Add(cc);
            message.Subject = subject;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml = format;
            message.Body = content;
            //message.f.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", server);
            //message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
            //message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
            //message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
            //message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user);
            //message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);

            try
            {
                SmtpMail.Send(message);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
